package Gameplay.Enemy;

import ADTs.PointADT;
import Gameplay.Level;
import Gameplay.Projectile.Projectile;
import Project.Main;

public class AI3 extends AI {

	int moveCooldown;
	long lastMove;
	int rotation;
	
	public AI3()
	{
		lastMove = 0;
		lastFired = 0;
		cooldown = 100;
		moveCooldown = 100000;
		rotation = 0;
	}
	
	public boolean move(Enemy e){
		/*if(moveCooldown + lastMove < System.currentTimeMillis())
		{
			if(e.getAcceleration().getX() > 0) {
				e.setAcceleration(new PointADT(1,0));
				e.getAcceleration().scale(20);
			} else {
				e.setAcceleration(new PointADT(-1,0));
				e.getAcceleration().scale(20);
			}
			lastMove = System.currentTimeMillis();
			return true;
		}*/
		return false;
	}
	/*@ requires enemyShootPathClean = true;
	  @	Projectile.aim.x = Player.x
	  @	Projectile.aim.y = Player.y
	  @*/
	public void attack(Enemy e) {
		if(lastFired + cooldown < System.currentTimeMillis())
		{
			PointADT dest = new PointADT(Math.cos(.0625 * Math.PI * rotation), Math.sin(.0625 * Math.PI * rotation));
			((Level) Main.getCurrentUI()).addToState(new Projectile(dest, e.getLocation().copy(), false));
			dest = new PointADT(Math.cos((.5 * Math.PI) + .0625 * Math.PI * rotation), Math.sin((.5 * Math.PI) + .0625 * Math.PI * rotation));
			((Level) Main.getCurrentUI()).addToState(new Projectile(dest, e.getLocation().copy(), false));
			dest = new PointADT(Math.cos(Math.PI + .0625 * Math.PI * rotation), Math.sin(Math.PI + .0625 * Math.PI * rotation));
			((Level) Main.getCurrentUI()).addToState(new Projectile(dest, e.getLocation().copy(), false));
			dest = new PointADT(Math.cos((1.5 * Math.PI) + .0625 * Math.PI * rotation), Math.sin((1.5 * Math.PI) + .0625 * Math.PI * rotation));
			((Level) Main.getCurrentUI()).addToState(new Projectile(dest, e.getLocation().copy(), false));
			
			lastFired = System.currentTimeMillis();
			rotation++;
		}
	}
}
